<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>
<%@ include file="/WEB-INF/jsp/common/taglib.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Index</title>
<link href="<s:url value="/css/standard.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/pop_up.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/maintenance.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/Simplemodal.css" />" rel="stylesheet"
	type="text/css" />

<script src='<c:url value="/js/common.js" />'></script>
<script src='<c:url value="/js/common_ui.js" />'></script>
<script src='<c:url value="/js/poplayer.js" />'></script>
<script src='<c:url value="/js/maint_ui.js" />'></script>
<script src='<c:url value="/js/jquery.DynamicMessage.js" />'></script>
<script src='<c:url value="/js/jquery.simplemodal-1.4.1.js" />'></script>
<script src='<c:url value="/js/jquery-1.7.2.js" />'></script>


</head>
<body>

	<form:form name="deleteForm" method="delete">
		<input type="hidden" name="id">
	</form:form>

	<form:form name="toPage" method="get">
		<input type="hidden" name="name" value="${conditionQuery.name}">
		<input type="hidden" name='grender' value="${conditionQuery.grender}">
		<input type="hidden" id="pageIndex" name="pageIndex" value="">
	</form:form>
	<div class="search">
		<form:form method="get" name="searchForm">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td>姓名:<input type="text" name="name"
						value="${conditionQuery.name}"> 性别: <select
						name='grender'>
							<option value="All"
								<c:if test="${conditionQuery.grender == 'All'}">selected</c:if>>All</option>
							<option value="Man"
								<c:if test="${conditionQuery.grender == 'Man'}">selected</c:if>>Man</option>
							<option value="Female"
								<c:if test="${conditionQuery.grender == 'Female'}">selected</c:if>>Female</option>
					</select> <input type='submit' onclick="search()" value=' 提交 ' />
					</td>
				</tr>
			</table>
		</form:form>
	</div>

	<div class="Info">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td width="7" align="left" valign="top" height="7"><img
					src="<s:url value="/images/corner_left_top_m.gif"/>" width="7"
					height="7" /></td>
				<td class="topBorderMain"><img
					src="<s:url value="/images/spacer.gif" />" /></td>
				<td width="7" align="right" valign="top"><img
					src="<s:url value="/images/corner_right_top_m.gif" />" /></td>
			</tr>

			<tr>
				<th colspan="4" class="mainFormTitle">EmployeeInfo</th>
			</tr>

			<tr>
				<td colspan="4" class="leftRightBorderMain">

					<table cellpadding="0" cellspacing="0" class="invoiceButton">
						<tr>
							<td><img src="<s:url value="/images/btn_add.gif"/>"
								name="btn_add.gif" align="absbottom" /> <a
								href="javascript:location.href='<c:url value='/employeeinfo/add' />'">Add
									New </a></td>
						</tr>
					</table>
					<table id="radiotable" class="mainGrid" width="100%" border="0"
						cellpadding="0" cellspacing="0">
						<thead>
							<tr>
								<th width='20%'>id</th>
								<th width='10%'>姓名</th>
								<th width='20%'>性别</th>
								<th width='10%'>职务</th>
								<th width='20%'>电话</th>
								<th width='20%'>地址</th>
								<th width='20%'>编辑</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${ list }" var="employee" varStatus="status">
								<tr id="radiotable_tr_<c:out value="${status.index}"/>">
									<td align='center' width='20%'><a
										href="javascript:location.href='<c:url value='/employeeinfo/${ employee.id }/view' />'">
											<c:out value="${ employee.id }" />
									</a></td>

									<td align='center' style="word-break: break-all;"><c:out
											value="${ employee.name }" /></td>
									<td align='center' width='20%' style="word-break: break-all;"><c:out
											value="${ employee.grender }" /></td>
									<td align='center' width='10%' style="word-break: break-all;"><c:out
											value="${ employee.title }" /></td>
									<td align='center' width='20%' style="word-break: break-all;"><c:out
											value="${ employee.tel }" /></td>
									<td align='center' width='20%' style="word-break: break-all;"><c:out
											value="${ employee.address }" /></td>

									<td align='center' style="white-space: nowrap;" width='20%'><a
										href="javascript:void(0);"
										onclick="location.href='<c:url value='/employeeinfo/${ employee.id }/edit' />'"><img
											src="<s:url value="/images/btn_edit.gif"/>"
											name="btn_edit.gif" alt="Edit" title="Edit" width="18"
											height="20" hspace="3" vspace="3" border="0"
											align="absmiddle" /></a>
											
											 <a href="javascript:void(0);"
										onclick="deleteDemo('<c:out value='${ employee.id }'/>')"><img
											src="<s:url value="/images/btn_remove.gif"/>"
											name="btn_remove.gif" alt="Remove" title="Remove" width="18"
											height="20" hspace="3" vspace="3" border="0"
											align="absmiddle" /></a></td>
								</tr>
							</c:forEach>

							<c:if test="${ list == null || fn:length(list) == 0}">
								<tr id="radiotable_tr_<c:out value="${status.index}"/>">
									<td colspan='99' align='center'><font color='red'>no
											recored.</font></td>
								</tr>
							</c:if>
						</tbody>
					</table>
				</td>
			</tr>
			<tr>
				<th colspan="4" class="mainFormbtn">
					<table cellpadding="0" cellspacing="0" width="100%">
						<tr>
							<td align="center">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td align="center">&nbsp;</td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
				</th>
			</tr>
			<tr></tr>
			<tr>
				<td align="left" valign="bottom" height="7" width="7"><img
					src="<s:url value="/images/corner_left_bottom_m.gif"/>" /></td>
				<td class="bottomBorderMain"><img
					src="<s:url value="/images/spacer.gif"/>" /></td>
				<td align="right" valign="bottom" height="7" width="7"><img
					src="<s:url value="/images/corner_right_bottom_m.gif"/>" /></td>
			</tr>
		</table>

	</div>



	<div class="pageVar">
		<c:set var='pageIndex' value='${pageIndex}' />
		<c:set var='pageSize' value="${pageSize}" />
		<c:set var='totalPage' value="${totalPage}" />

		<c:set var='changePercent' value="0.7" />
		<c:set var='changeStepSize' value="1" />


		<c:set var='starPageIndex' value="0" />
		<c:set var='endPageIndex' value="${pageSize}" />
		<c:set var='changeStep' value="0" />

		<c:if test="${pageIndex >= pageSize * changePercent}">
			<c:set var='changeStep'
				value="${
					 ( 
			 			(pageIndex - endPageIndex * changePercent + 1) 
							-
							(pageIndex - endPageIndex * changePercent + 1) %1 ) * changeStepSize}" />
			<!-- 减去自身的余数*增加页数值 -->

		</c:if>

		<c:set var="starPageIndex" value="${starPageIndex+changeStep}"></c:set>

		<c:set var="endPageIndex" value="${endPageIndex+changeStep}"></c:set>

		<c:set var="needEndValue" value="true" />

		<c:if test="${endPageIndex >= totalPage}">
			<c:set var="endPageIndex" value="${totalPage}" />
			<c:set var="needEndValue" value="false" />
		</c:if>


		<c:set var="isShowOmitSign" value="false" />

		<c:if test="${needEndValue}">

			<c:set var="isShowOmitSign" value="${totalPage > (endPageIndex)}" />


		</c:if>

	</div>
	<br>
	<div class="pageColumn" style="position:absolute;
bottom:80px">

		<form:form action="page"> 
		页数：【${pageIndex+1}】<a
				<c:choose> <c:when test="${pageIndex > 1}"> 
													href="javascript:goPage('${pageIndex-1}')"</c:when>
  					              <c:otherwise> href="javascript:goPage('0')"
   											</c:otherwise></c:choose>>【上一页】</a>
			<a href="javascript:goPage('${pageIndex + 1}')">【下一页】</a> 
			总页数：<input size="1" name="amount" value="${totalPage}" type="text">
		</form:form>
	</div>
	<br>
	<br>
	<div class="pageCodeShow" style="position:absolute;
bottom:50px">
		<table id="radiotable" class="mainGrid" style="width: 100%;">

			<tr>
				<td class="pageTd" align="center" width="250px"><a name="home"
					onclick="goPage('0')" class="pageButton"
					style="cursor: pointer; font-size: large; text-decoration: none; color: #404040;">home</a>

					&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <c:if
						test="${starPageIndex > 0}">
						<a name="previousPage" onclick="goPage('${pageIndex-1}')"
							class="pageButton"
							style="cursor: pointer; font-size: large; text-decoration: none; color: #404040;">上一页</a>

					</c:if></td>

				<c:forEach var="buttonCodeList" begin="${starPageIndex+1}"
					end="${endPageIndex}" step="1">

					<td class="pageTd" align="center" width="100px"><a
						name="buttonCode" onclick="goPage('${buttonCodeList-1}')"
						class="pageButton"
						style="cursor: pointer; text-decoration: none; color: #404040; font-size: 15px;">${buttonCodeList}</a>

					</td>
				</c:forEach>

				<td align="center" width="125px" class="pageTd"><c:if
						test="${needEndValue}">

						<c:if test="${isShowOmitSign}">
							<a name="totalPage" onclick="goPage('${totalPage}')"
								class="pageButton"
								style="cursor: pointer; text-decoration: none; color: #404040; font-size: 15px">...
								${totalPage}</a>
						</c:if>
						<c:if test="${!isShowOmitSign}">
							<a name="totalPage" onclick="goPage('${totalPage}')"
								class="pageButton"
								style="cursor: pointer; text-decoration: none; color: #404040;">${totalPage}</a>
						</c:if>
					</c:if></td>
				<td align="center" width="125px" class="pageTd"><c:if
						test="${endPageIndex < totalPage}">
						<a name="nextPage" onclick="goPage('${pageIndex+1}')"
							class="pageButton"
							style="cursor: pointer; font-size: large; text-decoration: none; color: #404040;">下一页</a>


					</c:if></td>
			</tr>

		</table>

	</div>
	<script type="text/javascript">
	
	function deleteDemo(id){
		if(confirm("Are you sure to delete this Record?")){
			$('#id').val(id);
			deleteForm.action="<c:url value='/employeeinfo/'/>" + id ;
			deleteForm.submit();
		}
	}
	
	function goPage(pageIndex){
		$('#pageIndex').val(pageIndex);
		toPage.action="<c:url value='/employeeinfo/page'/>";
		
		toPage.submit();
	}
	
	function search() {
		searchForm.action="<c:url value='/employeeinfo/page'/>";
		searchForm.submit();
	}
	
</script>

</body>

</html>